﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<Presentation.Models.FormViewModel>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	Edit <%: Model.Form.Name %>
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">

    <h2>Edit <%: Model.Form.Name %></h2>

    <table>
        <tr>
            <th>
                Options
            </th>
            <th>
                Position
            </th>
            <th>
                Name
            </th>
                <th>
                Type
            </th>
        </tr>

    <% foreach (var item in Model.Form.FormElements) { %>
    
        <tr>
            <td>
                <% if (!(item.Name.Equals("Name") || item.Name.Equals("Description"))) { %>
                   
                   <%: Html.ActionLink("Delete", "DeleteFormElement", new { formId = Model.Form.Id, name = item.Name })  %>

                <% } %>
                
            </td>
            <td>
                <%: item.Position %>
            </td>
            <td>
                <%: item.Name %>
            </td>
            <td>
                <%: item.Type %>
            </td>
        </tr>
    
    <% } %>

    </table>

    <% using (Html.BeginForm("AddFormElement", "Form", FormMethod.Post)) { %>

        <div>
            <fieldset>
                <legend>Add Form Element</legend>
                
                <div class="editor-label">
                    <%: Html.LabelFor(m => m.FormElement.Name) %>
                </div>
                <div class="editor-field">
                    <%: Html.TextBox("name") %>
                </div>
                
                <div class="editor-label">
                    <%: Html.LabelFor(m => m.FormElement.Type) %>
                </div>
                <div class="editor-field">
                   <%: Html.DropDownList("type", Model.TypeItems) %>
                </div>
                <p>
                    <%: Html.Hidden("formId", Model.Form.Id) %>
                    <input type="submit" value="Save" />
                </p>

            </fieldset>
        </div>

    <% } %>

    <p> 
        <%: Html.ActionLink("Back to list", "All") %>
    </p>

</asp:Content>

